(function() {
    Path.on('/admin/__basename__.html', function(_current_location) {
        App.set('admin_title', '图片资源');

        var qs = _current_location.query;
        var count = qs.get('count') || 12;
        App.set('$Cache.admin.sourceimages.count', count);
        var offset = qs.get('offset') || 0;

        // 拉取图片素材列表
        coAjax.get(apis.wx.business.sourceList + 'image', {
            count: count || 12,
            offset: offset || 0
        }, function(result) {
            console.log(result);
            App.set('$Cache.admin.sourceimages.list', result);
            var pages = [];
            pages.length = Math.ceil(result.total_count / count);
            App.set('$Cache.admin.sourceimages.pages', pages);
        }, function(errCode, errMsg, err) {
            alert('warn', errMsg);
        });
    });

    App.set('$Event.admin.sourceimages.delete', function(e, vm) {
        console.log(vm.get('media_id'));
        alert('warn', '功能暂未开放');
    })

}());
